import 'package:ble_demo/entity/scan_result_device_entity.dart';

scanResultDeviceEntityFromJson(ScanResultDeviceEntity data, Map<String, dynamic> json) {
	if (json['bleDevice'] != null) {
		data.bleDevice = new ScanResultDeviceBleDevice().fromJson(json['bleDevice']);
	}
	return data;
}

Map<String, dynamic> scanResultDeviceEntityToJson(ScanResultDeviceEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	if (entity.bleDevice != null) {
		data['bleDevice'] = entity.bleDevice.toJson();
	}
	return data;
}

scanResultDeviceBleDeviceFromJson(ScanResultDeviceBleDevice data, Map<String, dynamic> json) {
	if (json['device'] != null) {
		data.device = new ScanResultDeviceBleDeviceDevice().fromJson(json['device']);
	}
	if (json['key'] != null) {
		data.key = json['key'].toString();
	}
	if (json['mac'] != null) {
		data.mac = json['mac'].toString();
	}
	if (json['rssi'] != null) {
		data.rssi = json['rssi'] is String
				? int.tryParse(json['rssi'])
				: json['rssi'].toInt();
	}
	if (json['scanRecord'] != null) {
		data.scanRecord = json['scanRecord'].toString();
	}
	if (json['timestampNanos'] != null) {
		data.timestampNanos = json['timestampNanos'] is String
				? int.tryParse(json['timestampNanos'])
				: json['timestampNanos'].toInt();
	}
	return data;
}

Map<String, dynamic> scanResultDeviceBleDeviceToJson(ScanResultDeviceBleDevice entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	if (entity.device != null) {
		data['device'] = entity.device.toJson();
	}
	data['key'] = entity.key;
	data['mac'] = entity.mac;
	data['rssi'] = entity.rssi;
	data['scanRecord'] = entity.scanRecord;
	data['timestampNanos'] = entity.timestampNanos;
	return data;
}

scanResultDeviceBleDeviceDeviceFromJson(ScanResultDeviceBleDeviceDevice data, Map<String, dynamic> json) {
	if (json['address'] != null) {
		data.address = json['address'].toString();
	}
	if (json['addressForLog'] != null) {
		data.addressForLog = json['addressForLog'].toString();
	}
	if (json['appearance'] != null) {
		data.appearance = json['appearance'] is String
				? int.tryParse(json['appearance'])
				: json['appearance'].toInt();
	}
	if (json['bluetoothClass'] != null) {
		data.bluetoothClass = new ScanResultDeviceBleDeviceDeviceBluetoothClass().fromJson(json['bluetoothClass']);
	}
	if (json['bluetoothDock'] != null) {
		data.bluetoothDock = json['bluetoothDock'];
	}
	if (json['bondState'] != null) {
		data.bondState = json['bondState'] is String
				? int.tryParse(json['bondState'])
				: json['bondState'].toInt();
	}
	if (json['connected'] != null) {
		data.connected = json['connected'];
	}
	if (json['encrypted'] != null) {
		data.encrypted = json['encrypted'];
	}
	if (json['gearIsConnected'] != null) {
		data.gearIsConnected = json['gearIsConnected'];
	}
	if (json['leDeviceType'] != null) {
		data.leDeviceType = json['leDeviceType'] is String
				? int.tryParse(json['leDeviceType'])
				: json['leDeviceType'].toInt();
	}
	if (json['messageAccessPermission'] != null) {
		data.messageAccessPermission = json['messageAccessPermission'] is String
				? int.tryParse(json['messageAccessPermission'])
				: json['messageAccessPermission'].toInt();
	}
	if (json['phonebookAccessPermission'] != null) {
		data.phonebookAccessPermission = json['phonebookAccessPermission'] is String
				? int.tryParse(json['phonebookAccessPermission'])
				: json['phonebookAccessPermission'].toInt();
	}
	if (json['remoteRssf'] != null) {
		data.remoteRssf = json['remoteRssf'] is String
				? int.tryParse(json['remoteRssf'])
				: json['remoteRssf'].toInt();
	}
	if (json['simAccessPermission'] != null) {
		data.simAccessPermission = json['simAccessPermission'] is String
				? int.tryParse(json['simAccessPermission'])
				: json['simAccessPermission'].toInt();
	}
	if (json['type'] != null) {
		data.type = json['type'] is String
				? int.tryParse(json['type'])
				: json['type'].toInt();
	}
	return data;
}

Map<String, dynamic> scanResultDeviceBleDeviceDeviceToJson(ScanResultDeviceBleDeviceDevice entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['address'] = entity.address;
	data['addressForLog'] = entity.addressForLog;
	data['appearance'] = entity.appearance;
	if (entity.bluetoothClass != null) {
		data['bluetoothClass'] = entity.bluetoothClass.toJson();
	}
	data['bluetoothDock'] = entity.bluetoothDock;
	data['bondState'] = entity.bondState;
	data['connected'] = entity.connected;
	data['encrypted'] = entity.encrypted;
	data['gearIsConnected'] = entity.gearIsConnected;
	data['leDeviceType'] = entity.leDeviceType;
	data['messageAccessPermission'] = entity.messageAccessPermission;
	data['phonebookAccessPermission'] = entity.phonebookAccessPermission;
	data['remoteRssf'] = entity.remoteRssf;
	data['simAccessPermission'] = entity.simAccessPermission;
	data['type'] = entity.type;
	return data;
}

scanResultDeviceBleDeviceDeviceBluetoothClassFromJson(ScanResultDeviceBleDeviceDeviceBluetoothClass data, Map<String, dynamic> json) {
	if (json['deviceClass'] != null) {
		data.deviceClass = json['deviceClass'] is String
				? int.tryParse(json['deviceClass'])
				: json['deviceClass'].toInt();
	}
	if (json['majorDeviceClass'] != null) {
		data.majorDeviceClass = json['majorDeviceClass'] is String
				? int.tryParse(json['majorDeviceClass'])
				: json['majorDeviceClass'].toInt();
	}
	if (json['peripheralMinorClass'] != null) {
		data.peripheralMinorClass = json['peripheralMinorClass'] is String
				? int.tryParse(json['peripheralMinorClass'])
				: json['peripheralMinorClass'].toInt();
	}
	if (json['peripheralMinorSubClass'] != null) {
		data.peripheralMinorSubClass = json['peripheralMinorSubClass'] is String
				? int.tryParse(json['peripheralMinorSubClass'])
				: json['peripheralMinorSubClass'].toInt();
	}
	return data;
}

Map<String, dynamic> scanResultDeviceBleDeviceDeviceBluetoothClassToJson(ScanResultDeviceBleDeviceDeviceBluetoothClass entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['deviceClass'] = entity.deviceClass;
	data['majorDeviceClass'] = entity.majorDeviceClass;
	data['peripheralMinorClass'] = entity.peripheralMinorClass;
	data['peripheralMinorSubClass'] = entity.peripheralMinorSubClass;
	return data;
}